<link rel="stylesheet" href="__STATIC__/admin/lib/layui-v2.6.3/css/layui.css" media="all">
<body>
<div class="layuimini-container" style="margin;30px;">
    <div class="layuimini-main">
        
  
    <blockquote class="layui-elem-quote layui-text">
        请妥善保管你的账号密码，防止泄露造成您的财产损失,密码需要设置大于6字节且包含特殊符号
    </blockquote>      
        <form class="layui-form" action="">
            
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">账号</label>
                    <div class="layui-input-inline">
                        <input type="tel" name="name" lay-verify="账号" autocomplete="off" class="layui-input" readonly="true" value="{$user.username}">
                    </div>
                </div>
            </div>
            
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">新密码</label>
                    <div class="layui-input-inline">
                        <input type="password" name="password" lay-verify="密码" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>
            
            
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">确认密码</label>
                    <div class="layui-input-inline">
                        <input type="password" name="password_isok" lay-verify="密码" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>
            
        </form>
        <div class="layui-form-item">
        <button class="layui-btn" lay-submit="" onclick="save_password()" style="margin:30px;">保存</button>
        </div>
    </div>
</div>
</body>
{include file="public/jquery" /}
<script>
 function save_password(){
     var password_isok = $('input[name="password_isok"]').val(),password = $('input[name="password"]').val()
     if(!password){
         layer.msg('请输入密码');
         return;         
     }
     
     if(password.length < 6 || password_isok.length < 6){
         layer.msg('密码需要设置大于6字段');
         return;              
     }
     
     if(password.indexOf(""))
     
     if(!password_isok){
         layer.msg('请输入确认密码');
         return;         
     }
     if(password_isok != password){
         layer.msg('两次密码不一致');
         return;
     }
     
     
     if(containSpecial(password) == false){
         layer.msg('密码太简单了，必须包含有特殊字符');
         return;         
     }
     
     $.post('/console/index/save_password',{'password':password},function(res){
         if(res.code>0){
             layer.msg(res.msg);
             $('input[name="password_isok"]').val('');
             $('input[name="password"]').val('');
         }else{
             layer.msg(res.msg);
         }
     },'json');
 }
 
  function containSpecial(s){      
    var containSpecial = RegExp(/[(\ )(\~)(\!)(\@)(\#)(\$)(\%)(\^)(\&)(\*)(\()(\))(\-)(\_)(\+)(\=)(\[)(\])(\{)(\})(\|)(\\)(\;)(\:)(\')(\")(\,)(\.)(\/)(\<)(\>)(\?)(\)]+/);  
    
    return (containSpecial.test(s));      
}    

</script>